package com.itheima.tlias84.mapper;

import com.itheima.tlias84.Po.SelectClazzPageParam;
import com.itheima.tlias84.dto.SelectClazzDTO;
import com.itheima.tlias84.entity.Clazz;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ClazzMapper {

    /**
     * 查询所有班级
     * @return
     */
    @Select("select id,name,room,begin_date,end_date,master_id,subject,create_time,update_time from clazz")
    List<SelectClazzDTO>selectAll();

    /**
     * 根据id查询班级
     * @param id
     * @return
     */
    @Select("select id,name,room,begin_date,end_date,master_id,subject,create_time,update_time from clazz where id=#{id}")
    SelectClazzDTO selectClazzById(Integer id);

    /**
     * 分页查询班级
     */
    List<SelectClazzDTO> selectClazzByPage(@Param("p") SelectClazzPageParam param);

    /**
     * 添加班级
     */
    int insertClazz(@Param("p") Clazz param);

    /**
     * 根据id删除班级
     */
    int deleteById(Integer id);

    /**
     * 修改班级
     */
    int updateClazz(@Param("p") Clazz param);

    /**
     * 查询修改的部门是否与已经存在的是否相同
     */
    @Select("select id,name from clazz where name=#{p}")
    Clazz selectClazzByName(@Param("p") String name);

}
